#pragma once
#include <string>
#include "pthread.h"

typedef void* (*func_t)(void*);

class ThreadData
{
public:
    std::string _name;
    void* _args;
};

class Thread
{
public:
    Thread(int num,func_t callback,void* args)
        :_func(callback)
        {
            char nameBuffer[64];
            snprintf(nameBuffer,sizeof(nameBuffer),"Thread-%d",num);
            _name=nameBuffer;
            _data._args=args;
            _data._name=_name;
        }
    ~Thread()
    {}
    void start()
    {
        pthread_create(&_tid,nullptr,_func,(void*)&_data);
    }
    void join()
    {
        pthread_join(_tid,nullptr);
    }
    std::string name()
    {
        return _name;
    }
private:
	std::string _name;
	func_t _func;
	pthread_t _tid;
    ThreadData _data;
};